import { url,imgServer } from './index.js'
const http = {

	// 接口
	request(data) {
		return new Promise((resolve, reject) => {
			uni.request({
				url: url + data.url,
				method: data.method || "GET",
				data: data.params,
				header: {
					"content-Type": data.method == "get" ? "" : "application/json",
					"toApplet":"msd_admin"
				},
				success: res => {
					if (res.data.code == '200') resolve(res.data)
					else http.showTost(res.data.msg || '网络错误！请重试')
				}
			})
		});
	},
	showTost(text) {
		uni.showToast({
			title: text,
			icon: "none",
			duration: 2000
		})
	},
	getUrl(){
		return url;
	},
	getImgUrl(){
		return imgServer;
	}




}
export default http